import collections
import random
class Solution:

    def __init__(self, nums):
        self.dic = collections.defaultdict(list)
        for i in range(len(nums)):
            self.dic[nums[i]].append(i)

    def pick(self, target: int) -> int:
        l = self.dic[target]
        k = random.randint(0, len(l)-1)
        return l[k]
nums = [1,2,3,3,3]
solution = Solution(nums)
print(random.randint(0,3))
print(solution.pick(3))
print(solution.pick(3))
print(solution.pick(3))
print(solution.pick(3))
print(solution.pick(3))


